package com.zmsk.zmio.handler;

import android.content.Context;

import com.zmsk.zmio.inter.IIOHandler;
import com.zmsk.zmio.ysface88.YSGpioUtils;

public class YSOldHandler implements IIOHandler {


    public YSOldHandler (Context context) {
        initIOControl(context);
    }

    @Override
    public void initIOControl(Context context) {
        try {
            YSGpioUtils.upgradeRootPermissionForExport();
            if (YSGpioUtils.exportGpio(146)) {
                YSGpioUtils.upgradeRootPermissionForGpio(146);
            }
            YSGpioUtils.setGpioDirection(146, 0);
            if (YSGpioUtils.exportGpio(171)) {
                YSGpioUtils.upgradeRootPermissionForGpio(171);
            }
            YSGpioUtils.setGpioDirection(171, 0);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    public void stopIOControl(Context context) {

    }

    @Override
    public void noticeGateOpen(Context context, String idNumber) {
        YSGpioUtils.writeGpioValue(146, "0");
    }

    @Override
    public void noticeGateClose(Context context) {
        YSGpioUtils.writeGpioValue(146, "1");
    }

    @Override
    public void noticeWhiteLedOn(Context context) {
        YSGpioUtils.writeGpioValue(171, "0");
    }

    @Override
    public void noticeWhiteLedOff(Context context) {
        YSGpioUtils.writeGpioValue(171, "1");

    }

    @Override
    public void noticeInfraredLedOn(Context context) {

    }

    @Override
    public void noticeInfraredLedOff(Context context) {

    }

    @Override
    public void noticeRedLedOn(Context context) {

    }

    @Override
    public void noticeRedLedOff(Context context) {

    }

    @Override
    public void noticeGreenLedOn(Context context) {

    }

    @Override
    public void noticeGreenLedOff(Context context) {

    }

    @Override
    public void handleSlientInstall(String path) {

    }
}
